<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Valid</title>
</head>
<body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
    (async function () {
        // TODO 采坑记录，如果是跨域请求，每次 JSESSIONID 都在变，需要配置 {credentials: 'include'}
        await fetch(`http://${location.host}/login`, {
            method: 'POST',
            credentials: 'include',
            headers: {'Content-Type': 'application/json;charset=utf-8'},
            body: JSON.stringify({json: {username: 'admin', password: 'admin'}})
        }).then((res) => res.json()).then(json => console.log(json));

        const http = {
            POST: (url) => {
                return fetch(`http://${location.host}${url}`, {
                    method: 'POST',
                    credentials: 'include',
                    headers: {'Content-Type': 'application/json;charset=utf-8'},
                    body: JSON.stringify({json: {}})
                }).then((res) => res.json()).then(json => $('body').append(`<pre>${JSON.stringify(json, ' ', 2)}</pre>`))
            },
            PUT: (url) => {
                return fetch(`http://${location.host}${url}`, {
                    method: 'PUT',
                    credentials: 'include',
                    headers: {'Content-Type': 'application/json;charset=utf-8'},
                    body: JSON.stringify({json: {}})
                }).then((res) => res.json()).then(json => $('body').append(`<pre>${JSON.stringify(json, ' ', 2)}</pre>`))
            },
            PATCH: (url) => {
                return fetch(`http://${location.host}${url}`, {
                    method: 'PATCH',
                    credentials: 'include',
                    headers: {'Content-Type': 'application/json;charset=utf-8'},
                    body: JSON.stringify({json: {}})
                }).then((res) => res.json()).then(json => $('body').append(`<pre>${JSON.stringify(json, ' ', 2)}</pre>`))
            },
            DELETE: (url) => {
                return fetch(`http://${location.host}${url}`, {
                    method: 'DELETE',
                    credentials: 'include',
                    headers: {'Content-Type': 'application/json;charset=utf-8'}
                }).then((res) => res.json()).then(json => $('body').append(`<pre>${JSON.stringify(json, ' ', 2)}</pre>`))
            },
            GET: (url) => {
                return fetch(`http://${location.host}${url}`, {
                    method: 'GET',
                    credentials: 'include',
                    headers: {'Content-Type': 'application/json;charset=utf-8'}
                }).then((res) => res.json()).then(json => $('body').append(`<pre>${JSON.stringify(json, ' ', 2)}</pre>`))
            }
        };

        const arrs = `### hasNull
#GET http://localhost:8080/valid/0/hasNull
GET http://localhost:8080/valid/1/hasNull
Authorization: basic YWRtaW46YWRtaW4=

###
### notNull
#GET http://localhost:8080/valid/0/notNull
GET http://localhost:8080/valid/1/notNull
Authorization: basic YWRtaW46YWRtaW4=

###
### notBlank
#GET http://localhost:8080/valid/0/notBlank
#GET http://localhost:8080/valid/1/notBlank
GET http://localhost:8080/valid/2/notBlank
Authorization: basic YWRtaW46YWRtaW4=

###
### size
#GET http://localhost:8080/valid/0/size
#GET http://localhost:8080/valid/1/size
#GET http://localhost:8080/valid/2/size
#GET http://localhost:8080/valid/3/size
GET http://localhost:8080/valid/4/size
Authorization: basic YWRtaW46YWRtaW4=

###
### pattern
#GET http://localhost:8080/valid/0/pattern
#GET http://localhost:8080/valid/1/pattern
#GET http://localhost:8080/valid/2/pattern
GET http://localhost:8080/valid/3/pattern
Authorization: basic YWRtaW46YWRtaW4=

###
### notEmpty
#GET http://localhost:8080/valid/0/notEmpty
#GET http://localhost:8080/valid/1/notEmpty
#GET http://localhost:8080/valid/2/notEmpty
GET http://localhost:8080/valid/3/notEmpty
Authorization: basic YWRtaW46YWRtaW4=

###
### min
#GET http://localhost:8080/valid/0/min
GET http://localhost:8080/valid/1/min
Authorization: basic YWRtaW46YWRtaW4=

###
### max
#GET http://localhost:8080/valid/0/max
GET http://localhost:8080/valid/1/max
Authorization: basic YWRtaW46YWRtaW4=

###
### decimalMin
#GET http://localhost:8080/valid/0/decimalMin
GET http://localhost:8080/valid/1/decimalMin
Authorization: basic YWRtaW46YWRtaW4=

###
### decimalMax
#GET http://localhost:8080/valid/0/decimalMax
GET http://localhost:8080/valid/1/decimalMax
Authorization: basic YWRtaW46YWRtaW4=

###
### digits
#GET http://localhost:8080/valid/0/digits
GET http://localhost:8080/valid/1/digits
Authorization: basic YWRtaW46YWRtaW4=

###
### negative
#GET http://localhost:8080/valid/0/negative
GET http://localhost:8080/valid/1/negative
Authorization: basic YWRtaW46YWRtaW4=

###
### negativeOrZero
#GET http://localhost:8080/valid/0/negativeOrZero
GET http://localhost:8080/valid/1/negativeOrZero
Authorization: basic YWRtaW46YWRtaW4=

###
### positive
#GET http://localhost:8080/valid/0/positive
GET http://localhost:8080/valid/1/positive
Authorization: basic YWRtaW46YWRtaW4=

###
### positiveOrZero
#GET http://localhost:8080/valid/0/positiveOrZero
GET http://localhost:8080/valid/1/positiveOrZero
Authorization: basic YWRtaW46YWRtaW4=

###
### assertTrue
GET http://localhost:8080/valid/0/assertTrue
#GET http://localhost:8080/valid/1/assertTrue
Authorization: basic YWRtaW46YWRtaW4=

###
### assertFalse
#GET http://localhost:8080/valid/0/assertFalse
GET http://localhost:8080/valid/1/assertFalse
Authorization: basic YWRtaW46YWRtaW4=

###
### email
#GET http://localhost:8080/valid/0/email
#GET http://localhost:8080/valid/1/email
GET http://localhost:8080/valid/2/email
Authorization: basic YWRtaW46YWRtaW4=

###
### past
#GET http://localhost:8080/valid/0/past
GET http://localhost:8080/valid/1/past
Authorization: basic YWRtaW46YWRtaW4=

###
### future
#GET http://localhost:8080/valid/0/future
GET http://localhost:8080/valid/1/future
Authorization: basic YWRtaW46YWRtaW4=

###
### save
POST http://localhost:8080/valid/0
#POST http://localhost:8080/valid/1
#POST http://localhost:8080/valid/2
#POST http://localhost:8080/valid/3
#POST http://localhost:8080/valid/4
#POST http://localhost:8080/valid/5
#POST http://localhost:8080/valid/6
#POST http://localhost:8080/valid/7
#POST http://localhost:8080/valid/8
#POST http://localhost:8080/valid/9
#POST http://localhost:8080/valid/10
#POST http://localhost:8080/valid/11
#POST http://localhost:8080/valid/12
#POST http://localhost:8080/valid/13
#POST http://localhost:8080/valid/14
#POST http://localhost:8080/valid/15
#POST http://localhost:8080/valid/16
#POST http://localhost:8080/valid/17
#POST http://localhost:8080/valid/18
#POST http://localhost:8080/valid/19
#POST http://localhost:8080/valid/20
#POST http://localhost:8080/valid/21
#POST http://localhost:8080/valid/22
#POST http://localhost:8080/valid/23
#POST http://localhost:8080/valid/24
#POST http://localhost:8080/valid/25
#POST http://localhost:8080/valid/26
#POST http://localhost:8080/valid/27
#POST http://localhost:8080/valid/28
#POST http://localhost:8080/valid/29
#POST http://localhost:8080/valid/30
#POST http://localhost:8080/valid/31
#POST http://localhost:8080/valid/32
#POST http://localhost:8080/valid/33
#POST http://localhost:8080/valid/34
#POST http://localhost:8080/valid/35
#POST http://localhost:8080/valid/36
Authorization: basic YWRtaW46YWRtaW4=

###
### update
PUT http://localhost:8080/valid/0/1
#PUT http://localhost:8080/valid/1/1
#PUT http://localhost:8080/valid/2/1
#PUT http://localhost:8080/valid/3/1
#PUT http://localhost:8080/valid/4/1
#PUT http://localhost:8080/valid/5/1
#PUT http://localhost:8080/valid/6/1
#PUT http://localhost:8080/valid/7/1
#PUT http://localhost:8080/valid/8/1
#PUT http://localhost:8080/valid/9/1
#PUT http://localhost:8080/valid/10/1
#PUT http://localhost:8080/valid/11/1
#PUT http://localhost:8080/valid/12/1
#PUT http://localhost:8080/valid/13/1
Authorization: basic YWRtaW46YWRtaW4=

###
### deleteById
DELETE http://localhost:8080/valid/0/1
#DELETE http://localhost:8080/valid/1/1
#DELETE http://localhost:8080/valid/2/1
DELETE http://localhost:8080/valid/3/1
#DELETE http://localhost:8080/valid/4/1
#DELETE http://localhost:8080/valid/5/1
Authorization: basic YWRtaW46YWRtaW4=

###
### deleteByUid
DELETE http://localhost:8080/valid/0/1/1
#DELETE http://localhost:8080/valid/1/1/1
#DELETE http://localhost:8080/valid/2/1/1
#DELETE http://localhost:8080/valid/3/1/1
DELETE http://localhost:8080/valid/4/1/1
#DELETE http://localhost:8080/valid/5/1/1
#DELETE http://localhost:8080/valid/6/1/1
#DELETE http://localhost:8080/valid/7/1/1
Authorization: basic YWRtaW46YWRtaW4=

###
### markDeleteById
PATCH http://localhost:8080/valid/0/1
#PATCH http://localhost:8080/valid/1/1
#PATCH http://localhost:8080/valid/2/1
PATCH http://localhost:8080/valid/3/1
#PATCH http://localhost:8080/valid/4/1
#PATCH http://localhost:8080/valid/5/1
Authorization: basic YWRtaW46YWRtaW4=

###
### markDeleteByUid
PATCH http://localhost:8080/valid/0/1/1
#PATCH http://localhost:8080/valid/1/1/1
#PATCH http://localhost:8080/valid/2/1/1
#PATCH http://localhost:8080/valid/3/1/1
PATCH http://localhost:8080/valid/4/1/1
#PATCH http://localhost:8080/valid/5/1/1
#PATCH http://localhost:8080/valid/6/1/1
#PATCH http://localhost:8080/valid/7/1/1
Authorization: basic YWRtaW46YWRtaW4=

###
### markDelete
PATCH http://localhost:8080/valid/0
#PATCH http://localhost:8080/valid/1
#PATCH http://localhost:8080/valid/2
#PATCH http://localhost:8080/valid/3
#PATCH http://localhost:8080/valid/4
PATCH http://localhost:8080/valid/5
#PATCH http://localhost:8080/valid/6
#PATCH http://localhost:8080/valid/7
#PATCH http://localhost:8080/valid/8
#PATCH http://localhost:8080/valid/9
Authorization: basic YWRtaW46YWRtaW4=

###
### findByIdTimestamp
GET http://localhost:8080/valid/0/1/1
#GET http://localhost:8080/valid/1/1/1
#GET http://localhost:8080/valid/2/1/1
Authorization: basic YWRtaW46YWRtaW4=

###
### findByUidTimestamp
GET http://localhost:8080/valid/0/1/1/1
#GET http://localhost:8080/valid/1/1/1/1
#GET http://localhost:8080/valid/2/1/1/1
Authorization: basic YWRtaW46YWRtaW4=

###
### search
GET http://localhost:8080/valid/0
#GET http://localhost:8080/valid/1
#GET http://localhost:8080/valid/2
Authorization: basic YWRtaW46YWRtaW4=

###
### page
GET http://localhost:8080/valid/0/page/1/1
#GET http://localhost:8080/valid/1/page/1/1
#GET http://localhost:8080/valid/2/page/1/1
Authorization: basic YWRtaW46YWRtaW4=

###
`.trim().split(/\n/)
                .map(v => v.trim()
                    .replace(/^#/, '')
                    .replace(/^##$/, '')
                    .replace(/^Authorization.*$/, '')
                    .replace('http://localhost:8080', '')
                )
                .filter(Boolean)
            // .map(v => {
            //     console.log(v);
            //     return v
            // })
        ;
        let name = '';
        for (let i = 0; i < arrs.length; i++) {
            if (arrs[i].startsWith('#')) {
                name = arrs[i];
                continue;
            }
            const [method, url] = arrs[i].split(' ');
            $('body').append(`<h3>${name}:${method}:${url}</h3>`);
            await http[method](url)
        }
    })();
</script>
</body>
</html>